package com.woniu.controller;

import com.woniu.entity.MaterialRequisition;
import com.woniu.service.MaterialRequisitionService;

import com.woniu.util.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
@RestController
@RequestMapping("/mr")
public class MaterialRequisitionController {

    @Resource
    private MaterialRequisitionService materialRequisitionService;

    // 查全部
    @GetMapping
    public ResponseUtil findAll() {
        return materialRequisitionService.findAll();
    }

    // 根据 procureId 查
    @GetMapping("/{requisitionId}")
    public ResponseUtil findByRequisitionId(@PathVariable Integer requisitionId) {
        return materialRequisitionService.findByRequisitionId(requisitionId);
    }

    // 新增
    @PostMapping
    public ResponseUtil add(@RequestBody MaterialRequisition materialRequisition) {
        return materialRequisitionService.add(materialRequisition);
    }

    // 删除
    @DeleteMapping("/{requisitionId}")
    public ResponseUtil delete(@PathVariable Integer requisitionId) {
        return materialRequisitionService.delete(requisitionId);
    }

    // 修改
    @PutMapping
    public ResponseUtil update(@RequestBody MaterialRequisition materialRequisition) {
        return materialRequisitionService.update(materialRequisition);
    }

    @GetMapping("/voList")
    public ResponseUtil voList(){
        return materialRequisitionService.queryVoList();
    }
}
